// 1. 引入http模块
let http = require("http")
let querystring = require("querystring")

// 2. 创建server对象
let server  = http.createServer(function(req, resp){

    console.log(req.url)
    let str = req.url.split("?")[1]
    let obj = querystring.parse(str)
    console.log(obj)

    resp.setHeader("content-type", "text/html;charset=utf8")
    resp.end("<h2>马上要放学了, 我很开心</h2>")
})

// 3. 绑定端口的监听
server.listen(3000, (err) => {
    if(!err){
        console.log("服务器启动成功了")
    }else{
        console.log(err)
    }
})